<?php
//模块插件类
//插件功能类，由系统调用，实现具体功能。
defined('BY_JYA') or exit('error');
class core_jy_quan extends plugin{
	public function __construct($name){
		global $_RQ;
		parent::__construct($name);
		set_exi(function($message,$type='success',$action='',$url=''){
			if(is_array($message) && !isset($message[0])){
				$message['pluginset']=$this->plugin_setting('basic');
				$message['pluginset']['open_types']=$message['pluginset']['open_types']?:';0;1;2;3;4;5;6;7;8;';
			}
			exi($message,$type,$action,$url);
		});
	}
	public function add_member($pid=0,$formuid=0,$snsid=0,$quanid=0,$pcd='',$action='') {
		$member=pdo_get('core_members',array('id'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),array('credit1','credit2','mobile','groupid','avatar','nickname'));
		if(empty($member)){
			$action=$action?:'jy_quan/myhome/';
			cfc('core')->checklogin($action);
		}
		$user=pdo_get('jy_quan_member',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),array('id','title','logo'));
		if(!$user['id']){
			$insert=array(
				'mid'=>$_SESSION['uid'],
				'uniacid'=>$_SESSION['uniacid'],
				'pid'=>intval($pid),
				'quanid'=>intval($quanid),
				'snsid'=>intval($snsid),
				'formuid'=>intval($formuid),
				'title'=>$member['nickname'],
				'logo'=>$member['avatar'],
				'desc'=>'大家好！欢迎浏览我的圈,里面记录了我在不同地点的一些生活趣事,也有我的小店！欢迎选购！',
				'pcd'=>$pcd,
				'createtime'=>TIMESTAMP,
			);
			pdo_insert('jy_quan_member',$insert);
		}elseif(!$user['title']){
			pdo_update('jy_quan_member',array('title'=>$member['nickname'],'logo'=>$member['avatar']),array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
		}
	}
}
?>